package com.wm.blog_search_interface.feign.factory;

import com.wm.blog_search_interface.feign.SearchFeignClient;
import com.wm.blog_search_interface.feign.fallback.SearchClientFallbackImpl;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 搜索服务断路器工厂
 *
 * @author 半卷流年        hystrix服务降级
 * @date 2019/3/23 23:38
 */
@Component
@Slf4j
public class SearchClientFallbackFactory implements FallbackFactory<SearchFeignClient> {

    @Override
    public SearchFeignClient create(Throwable throwable) {
        SearchClientFallbackImpl searchClientFallback = new SearchClientFallbackImpl();
        searchClientFallback.setThrowable(throwable);
        log.info("调用搜索服务feign异常:{}",throwable);
        return searchClientFallback;
    }
}
